/**
* @Description: WoShop商城
* @Author: 梧桐
* @Copyright: 武汉一一零七科技有限公司©版权所有
* @Link: www.wo-shop.net
* @Contact: QQ:2487937004
*/
<!-- 我的评价 -->
<template>
	<view class="page">
		<view class="content">
			<!-- 全部订单 -->
			<view class="list">
				<view class="listItem" v-for="(comment,index) in commentList" :key="index"
					@click="getnav('/pagesB/seller/orderDetails?order_num=' +comment.ordernumber)">
					<image class="orderStatusImg"
						:src="comment.filter==5?imgSTATICURL+'images/icon-orderFail.png':''" />
					<view class="orderStatus">
						<view class="orderNo f24 c9">{{$t('订单号')}}:{{comment.ordernumber}}</view>
					</view>
					<view class="goods">
						<u-image class="goodsPic" mode="aspectFill" width="160" height="160" border-radius="15"
							:src="comment.goodsinfo.thumb_url?comment.goodsinfo.thumb_url:imgSTATICURL+'images/img-goodsNull@2x.png'">
						</u-image>

						<view class="goodsInfo">
							<view class="goodsName f26 c3">{{comment.goodsinfo.goods_name}}</view>
							<view class="totalPrice f22 c6">{{$t('共')}}{{comment.goodsinfo.goods_num}}{{$t('件宝贝,应付')}}<text
									class="priceNum">{{$t('¥')}}{{comment.total_price}}</text></view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<loadMore :loadingType="loadingType"></loadMore>
	</view>
</template>

<script>
	import uniRate from '@/components/uni-rate/uni-rate.vue';

	export default {
		components: {
			uniRate,
		},
		data() {
			return {
				imgSTATICURL: this.STATICURL,
				commentList: [],
				page: 1,
				delSrc: ''
			}
		},
		onLoad() {

			let params = {
				size: "5",
				page: 1,
				filter: 7
			};
			this.getCartApraiseList(params);
			uni.setNavigationBarTitle({
				title: this.$t('订单失败')
			});
		},

		onReachBottom() {

			let params = {
				size: "5",
				page: 1,
				filter: 7
			};
			this.loadMoreFunc(params);
		},
		onPullDownRefresh() {
			this.page = 1
			this.$nextTick(() => {
				this.getCartApraiseList({
					size: "5",
					page: 1,
					filter: 7
				}, true);
			})

		},
		methods: {
			getCartApraiseList(data, refresh) {
				if (this.page == 1) {
					this.$loading();
				}
				this.$http.getShopperOrderList(data).then(res => {
					if (res.status === 200) {
						this.$hideLoading();
						if (refresh) {
							this.commentList = res.data;
							this.loadingType = 0;
							return false
						}
						if (res.data.length == 0) {
							
							this.loadingType = 2;
							return false;
						}
						this.commentList = this.commentList.concat(res.data);
						this.loadingType = 0;
					}
					// uni.stopPullDownrefrash();
				}).catch(() => {
					// uni.stopPullDownrefrash();
				})
			},


			loadMoreFunc: function(params) {
				// 加载函数

				if (this.loadingType == 1 || this.loadingType == 2) {
					return false;
				}
				this.loadingType = 1;
				
				++this.page;
				params.page = this.page;

				this.$nextTick(() => {
					this.getCartApraiseList(params);
				})
			},


			preview: function(urls, urlsId) {
				uni.previewImage({
					current: urlsId, //当前显示的 图片
					indicator: "number",
					urls: urls // 预览图片的列表
				});
			}
		}
	};
</script>

<style lang="less" scoped>
	page {
		background: #f4f4f4;
	}

	.page {
		.listItem {
			background-color: #ffffff;
			margin: 30rpx;
			border-radius: 20rpx;
			padding: 30rpx;
			position: relative;
		}

		.orderStatusImg {
			position: absolute;
			top: 0rpx;
			right: 14rpx;
			width: 208rpx;
			height: 142rpx;
			opacity: 0.6;
		}

		.goods {
			display: flex;
			flex-direction: row;
			justify-content: flex-start;

			.goodsPic {
				flex-shrink: 0;
			}

			.goodsInfo {
				margin-left: 18rpx;
				display: flex;
				justify-content: space-between;
				flex-direction: column;

				.priceNum {
					color: #FA3E3F;
					font-size: 36rpx;
					font-weight: 600;
					margin-left: 8rpx;
				}
			}
		}
	}
</style>
